
package nccloud.web.hrppl.pjapplication.pjappl.action;

import java.util.Objects;

import nc.itf.org.IOrgResourceCodeConst;
import nccloud.framework.web.processor.refgrid.RefQueryInfo;
import nccloud.framework.web.ui.meta.RefMeta;
import nccloud.web.refer.DefaultGridRefAction;

/**
 *
 * 默认表格参照
 *
 * @author zx
 *
 */
public class PjapplDefaultGridRefAction extends DefaultGridRefAction {

	public PjapplDefaultGridRefAction() {
		super();
		setResourceCode(IOrgResourceCodeConst.ORG);
	}

	@Override
	public RefMeta getRefMeta(RefQueryInfo refQueryInfo) {
		RefMeta refMeta = new RefMeta();
		setResourceCode(IOrgResourceCodeConst.ORG);
		refMeta.setCodeField("billno");
		refMeta.setNameField("pjname");
		refMeta.setExtraFields(new String[] {"DECODE(pjlibcategory, 1,'草稿库',2,'审批库',3,'备选库',4,'项目库',5,'淘汰库', pjlibcategory)  as  pjlibcategory", "def1"});
		refMeta.setPkField("pk_pjappl");
		refMeta.setTableName("hrppl_pjappl");
		refMeta.setMutilLangNameRef(true);
		return refMeta;
	}

	@Override
	public String getExtraSql(RefQueryInfo paramRefQueryInfo, RefMeta paramRefMeta) {
		StringBuffer sql = new StringBuffer();
		String pjstatus = paramRefQueryInfo.getQueryCondition().get("pjstatus");
		if (Objects.nonNull(pjstatus)) {
			sql.append(" and pjstatus in ('1','2','3') ");
		}
		String pjlibcategory = paramRefQueryInfo.getQueryCondition().get("pjlibcategory");
		if (Objects.nonNull(pjlibcategory)) {
			sql.append(" and pjlibcategory in ('4') " ); // modify by wy 备选库 3
		}
		String pk_org = paramRefQueryInfo.getQueryCondition().get("pk_org");
		if (Objects.nonNull(pk_org)) {
			sql.append(" and pk_org = '"+pk_org	+ "' " );
		}
		// modify by wy at 2024年9月2日
		String islastversion = paramRefQueryInfo.getQueryCondition().get("islastversion");
		if (Objects.isNull(islastversion)) {
			sql.append(" and islastversion = 'Y' ");
		}else {
			sql.append(" and islastversion = '"+islastversion+"' ");
		}
		return sql.toString();
	}

}
